package com.xyh.mapper;

import com.xyh.entity.YxcAmount;
import com.xyh.entity.YxcCar;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface YxcCarMapper {
    @Select("select * from yxc_car where owner_telephone = #{login_telephone} and flag = 1")
    List<YxcCar> selectAllCarByphone(@Param("login_telephone") String login_telephone);

    @Update("update yxc_car set flag = 0 where car_id = #{car_id} and owner_telephone = #{owner_telephone}")
    int deleteOneCar(@Param("car_id") int car_id,@Param("owner_telephone") String owner_telephone);

    @Insert("insert yxc_car(car_number,number_color,car_owner,owner_telephone) values(#{car_number},#{number_color},#{car_owner},#{owner_telephone})")
    int addOneCarByPhone(YxcCar yxcCar);

    @Select("select * from yxc_car ${whereCondition}")
    YxcCar selectOneCarByphoneAndPage(String whereCondition);

    @Update("update yxc_car set is_init = #{is_init} where car_id = #{car_id} and flag = 1")
    int updateIsInitById(@Param("car_id") int car_id,@Param("is_init") int i);

    @Select("select count(*) from yxc_car where owner_telephone = #{owner_telephone} and is_init = 1 and flag = 1")
    int getInitCarCount(@Param("owner_telephone") String login_telephone);

    @Select("select car_id from yxc_car where car_number = #{car_number} and flag = 1")
    Integer getCarIdByCarNumber(@Param("car_number") String car_number);
}
